package jvs.sh.std;

import java.net.URI;
import java.util.List;

import jvs.vfs.FileSystem;
import jvs.vfs.sec.AccessControl;
import jvs.vfs.sec.User;
import x.java.io.File;

public class BasicAccessControl implements AccessControl {
	private static final String GROUP = "/group";
	private static final URI GROUP_URI = newURI("group:/");
	private static File groupFolder;
	
	private static URI newURI(String uri) {
		try {
			return new URI(uri);
		} catch (Exception e) {
		}
		return null;
	}

	public BasicAccessControl() {
		initAccessControl();
	}
	
	// /group/ mounted? if not, auto mount if buddy:/ is supported
	synchronized private static void initAccessControl() {
		if (groupFolder != null && groupFolder.exists()) {
			return;
		}
		try {
			FileSystem.getFileSystem().mount(GROUP, GROUP_URI, "rw");
			groupFolder = new File(GROUP);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public boolean addGroup(String group) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean addPrincipal(String principal, String name, String group) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean checkGroup(String principal, String group) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean checkGroup(String group) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean checkPrincipal(String principal) {
		// TODO Auto-generated method stub
		return false;
	}

	public List<jvs.vfs.sec.Group> getGroups(String principal) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<User> getPrincipals(String group) {
		// TODO Auto-generated method stub
		return null;
	}

	public List<jvs.vfs.sec.Group> groups() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean removeGroup(String group) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean removePrincipal(String principal, String group) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean updateGroup(String group, String desc) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean updateUser(String principal, String name) {
		// TODO Auto-generated method stub
		return false;
	}

	public List<User> users() {
		// TODO Auto-generated method stub
		return null;
	}

	public jvs.vfs.sec.Group findGroup(String gid) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public User findUser(String uid) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public User findUser(String gid, String uid) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean removeUser(String uid) {
		// TODO Auto-generated method stub
		return false;
	}

}
